Chore: Improve ai-code-implement-todo inside org-mode file#325
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e95a8056c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (if (and (string-prefix-p "/" final-prompt) | ||
| (not (string-match-p " " final-prompt))) | ||
| (ai-code--execute-command final-prompt) |
There was a problem hiding this comment.
Preserve slash command execution in prompt-mode headings
When summary appending is enabled on an ai-code-prompt-mode heading, command detection now checks final-prompt instead of the original command text, so a slash command like /status can be converted into a normal prompt and no longer run via ai-code--execute-command. This regression only appears in heading-based prompt buffers (for example task files under .ai.code.files) and breaks direct backend command workflows that previously executed immediately.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
Enhances ai-code-implement-todo-driven workflows for Org buffers by treating plain Org headlines as implementable prompts (excluding DONE) and adding an optional “append result summary in-place” instruction when operating inside ai-code-prompt-mode task files.
Changes:
- Expand Org headline detection so
ai-code-implement-todo(and routing fromai-code-code-change/ai-code-ask-question) works on plain Org headlines, not only TODO headlines. - Move the “append result summary” prompt/instruction into
ai-code--insert-promptwhen inai-code-prompt-modeat a heading. - Add/adjust ERT coverage for plain Org headline behavior and the new summary-appending flow.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
ai-code-change.el |
Broadens Org headline detection and updates prompt/error strings to reflect “Org headline” (not only TODO). |
ai-code-prompt-mode.el |
Adds optional summary-append instruction during prompt insertion in ai-code-prompt-mode headings. |
test/test_ai-code-change.el |
Adds tests for plain Org headlines and summary logic (some currently misconfigured to use org-mode). |
test/test_ai-code-discussion.el |
Adds routing test ensuring ai-code-ask-question goes to ai-code-implement-todo on plain Org headlines. |
| (let* ((processed-prompt (if ai-code-prompt-preprocess-filepaths | ||
| (ai-code--preprocess-prompt-text prompt-text) | ||
| prompt-text)) | ||
| (append-summary-p (and (derived-mode-p 'ai-code-prompt-mode) | ||
| (org-at-heading-p) | ||
| (y-or-n-p "Append result summary to current section? "))) | ||
| (final-prompt (if append-summary-p | ||
| (concat processed-prompt | ||
| (format "\n\nAfter completing, append a concise result summary as a sub-heading at the end of the current section in file %s near line %d." | ||
| buffer-file-name (line-number-at-pos))) | ||
| processed-prompt))) | ||
| (if (and (string-prefix-p "/" final-prompt) | ||
| (not (string-match-p " " final-prompt))) | ||
| (ai-code--execute-command final-prompt) | ||
| (ai-code--write-prompt-to-file-and-send final-prompt)))) |
| (require 'org) | ||
| (setq buffer-file-name "/tmp/project/plan.org") | ||
| (insert "* TODO Build search feature\n") | ||
| (insert "Design the API first.\n") | ||
| (org-mode) | ||
| (goto-char (point-min)) | ||
|
|
| (require 'org) | ||
| (setq buffer-file-name "/tmp/project/plan.org") | ||
| (insert "* TODO Build search feature\n") | ||
| (insert "Design the API first.\n") | ||
| (org-mode) | ||
| (goto-char (point-min)) | ||
|
|
| (cond | ||
| ((and ask-question-p org-todo-section-info) | ||
| (if (and clipboard-context (string-match-p "\\S-" clipboard-context)) | ||
| "Question about Org TODO headline (clipboard context): " | ||
| "Question about Org TODO headline: ")) | ||
| "Question about Org headline (clipboard context): " | ||
| "Question about Org headline: ")) |
This is an enhancement after #317